package com.xiaolun.controller;

import com.xiaolun.mapper.UserMapper;
import com.xiaolun.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author 硕鼠
 * @Date 2020/4/11 10:37
 * @Version 1.0
 * @Description 文件说明
 */
@Controller
public class UserDelete {

    @Autowired
    private UserMapper userMapper;

    @RequestMapping("/delete")
    @ResponseBody
    public Map<String,Object> newsDelete(int id){
        System.out.println("id的值:"+ id);
        int delResult = this.userMapper.deleteUser(id);
        //接收参数再返回到表格中
        Map <String,Object> map = new HashMap<>();//放在这里
        List <User> list  = this.userMapper.findAll(); //找到所有数据
        map.put("data",list); //取得数据
        map.put("count",list.size()); //取得数据量
        map.put("code",0); //取得数据
        return map;
    }
}
